package route

import (
	"Family/app/controller"
	"Family/library"
	"github.com/gin-gonic/gin"
)

// 初始化路由
func initRoute() *gin.Engine {
	route := gin.Default()
	// 加载路由
	loadRoute(route)
	return route
}

// 加载路由
func loadRoute(route *gin.Engine) {
	member := route.Group("/api/member")
	{
		// index路由
		member.POST("/add", Middleware, controller.AddMember)
		member.POST("/update", Middleware, controller.UpdateMember)
		member.GET("/list", Middleware, controller.GetList)
		member.POST("/del", Middleware, controller.DelMember)
		member.GET("/getMemberList", Middleware, controller.GetMemberList)
		member.GET("/getMateList", Middleware, controller.GetMateList)
		member.POST("/setMate", Middleware, controller.SetMate)
	}
}

func Run() {
	route := initRoute()
	// 从配置信息中获取请求的端口
	route.Run(":" + library.ConfigParam.App.Port)
}
